//
//  ACPlayBackViewController.m
//  ACLiteAVUISDK
//
//  Created by 冯琰琰 on 2021/3/29.
//

#import "ACPlayBackViewController.h"
#import "ACLiveModel.h"
#import "ACPlayBackListCell.h"
#import "ACPlayBackMainViewController.h"

@interface ACPlayBackViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)NSMutableArray<ACLiveModel *>*dataArray;
@property(nonatomic,assign)int page;
@end

@implementation ACPlayBackViewController
-(UITableView *)tableview{
    if (!_tableview) {
        _tableview = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.estimatedRowHeight = 260;
        _tableview.backgroundColor = UIColorFromRGB(0xF4F5F8);
        _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        NSBundle *curB = [NSBundle BundleWithBundleName:ACLiteAVUISDK targetClass:[self class] ];
        [_tableview registerNib:[UINib nibWithNibName:@"ACPlayBackListCell" bundle:curB] forCellReuseIdentifier:@"ACPlayBackListCell"];
    }
    return _tableview;
}
- (NSMutableArray<ACLiveModel *> *)dataArray{
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.page = 1;
    [self.view addSubview:self.tableview];
    
    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    @weakify(self);
    self.tableview.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        @strongify(self)
        self.page = 1;
        [self requestData];
    }];
    self.tableview.mj_footer = [MJRefreshBackFooter footerWithRefreshingBlock:^{
        @strongify(self)
        self.page += 1;
        [self requestData];
    }];
//    [self.tableview.mj_header beginRefreshing];
}
-(void)requestData{
    
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return self.dataArray.count;
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ACPlayBackListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ACPlayBackListCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[ACPlayBackListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ACPlayBackListCell"];
    }
//    ACLiveModel *liveModel = self.dataArray[indexPath.row];
//    cell.liveModel = liveModel;
    return  cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ACPlayBackMainViewController *playBackMainVC = [[ACPlayBackMainViewController alloc] init];
    [self.navigationController pushViewController:playBackMainVC animated:YES];
}
#pragma mark - JXCategoryListContentViewDelegate

/**
 实现 <JXCategoryListContentViewDelegate> 协议方法，返回该视图控制器所拥有的「视图」
 */
- (UIView *)listView {
    return self.view;
}
@end
